home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / XPK / Source / test / testFileUnpack.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-15  |  1.9 KB  |  86 lines

  1. #define NAME     "testFileUnpack"
  2. #define REVISION "0"
  3. #define ENDCODE_NOCTRLC
  4.  
  5. /* Programmheader
  6.  
  7.     Name:        testFileUnpack
  8.     Author:        SDI
  9.     Distribution:    PD
  10.     Description:    easy file to file unpacker
  11.     Compileropts:    -
  12.     Linkeropts:    -l xpkmaster amiga
  13.  
  14.  1.0   24.03.97 : first version
  15. */
  16.  
  17. #include <pragma/exec_lib.h>
  18. #include <pragma/dos_lib.h>
  19. #include <pragma/xpkmaster_lib.h>
  20. #include "SDI_defines.h"
  21.  
  22. #ifdef __MAXON__
  23.   #define __asm
  24.   #define __saveds
  25. #endif
  26.  
  27. struct Library        *XpkBase        = 0;
  28. ULONG            DosVersion        = 37;
  29. struct RDArgs        *rda            = 0;
  30.  
  31. #define PARAM "FROM/A,TO/A"
  32.  
  33. LONG __asm __saveds chunkfunc(register __a1 struct XpkProgress *prog)
  34. {
  35.   switch(prog->xp_Type)
  36.   {
  37.   case XPKPROG_START: PutStr("Start: "); break;
  38.   case XPKPROG_MID: PutStr("\rMid  : "); break;
  39.   case XPKPROG_END: PutStr("\rEnd  : "); break;
  40.   }
  41.  
  42.   if(prog->xp_Type != XPKPROG_END)
  43.     Printf("%4s: %-8s (%3ld%% done, %2ld%% CF, %6ld cps) %s",
  44.       prog->xp_PackerName, prog->xp_Activity, prog->xp_Done,
  45.       prog->xp_CF, prog->xp_Speed, prog->xp_FileName);
  46.   else
  47.     Printf("%4s: %-8s (%3ldK, %2ld%% CF, %6ld cps) %s\033[K\n",
  48.       prog->xp_PackerName, prog->xp_Activity, prog->xp_ULen >> 10,
  49.       prog->xp_CF, prog->xp_Speed, prog->xp_FileName);
  50.  
  51.   Flush(Output());
  52.   return (LONG) SetSignal(0, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C;
  53. }
  54.  
  55. struct Hook chunkhook = { {0}, (ULONG (*)()) chunkfunc};
  56.  
  57. void main(void)
  58. {
  59.   UBYTE errbuf[XPKERRMSGSIZE+1];
  60.   struct {
  61.     STRPTR from;
  62.     STRPTR to;
  63.   } args = {0,0};
  64.  
  65.   if(!(rda = ReadArgs(PARAM, (LONG *) &args, 0)) ||
  66.   !(XpkBase = OpenLibrary(XPKNAME, 3)))
  67.     End(RETURN_FAIL);
  68.  
  69.   if(XpkUnpackTags(XPK_InName, args.from, XPK_OutName, args.to,
  70.   XPK_GetError, errbuf, XPK_ChunkHook, &chunkhook, TAG_DONE))
  71.   {
  72.     STRPTR a = errbuf;
  73.     VPrintf("Can't XpkUnpack: %s\n", &a);
  74.     End(RETURN_FAIL);
  75.   }
  76.  
  77.   End(RETURN_OK);
  78. }
  79.  
  80. void end(void)
  81. {
  82.   if(XpkBase)    CloseLibrary(XpkBase);
  83.   if(rda)    FreeArgs(rda);
  84. }
  85.  
  86.